package org.ytor.core.sysapi.user.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import org.ytor.common.util.bean.Beans;
import org.ytor.core.sqlflow.PersistenceModel;
import org.ytor.core.sqlflow.anno.Table;
import org.ytor.core.sqlflow.enums.IdType;
import org.ytor.core.sysapi.user.resp.SysUserResp;

import java.time.LocalDate;

/**
 * created by   on 2025年4月9日 23:03:21
 * <br/>
 * User表实体类
 * <br/>
 */
@Data
@Accessors(chain = true)
@Schema(description = "用户表")
@EqualsAndHashCode(callSuper = true)
@Table(value = "sys_user", idType = IdType.SNOWFLAKE)
public class SysUser extends PersistenceModel<SysUser, String> {

    /**
     * 用户名
     */
    @Schema(description = "用户名")
    private String userName;

    /**
     * 真实姓名
     */
    @Schema(description = "真实姓名")
    private String realName;

    /**
     * 密码
     */
    @Schema(description = "密码")
    private String password;

    /**
     * 头像
     */
    @Schema(description = "头像")
    private String avatar;

    /**
     * 手机号码
     */
    @Schema(description = "手机号码")
    private String phone;

    /**
     * 邮箱
     */
    @Schema(description = "邮箱")
    private String email;

    /**
     * 生日
     */
    @Schema(description = "生日")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;

    /**
     * 身份证
     */
    @Schema(description = "身份证")
    private String idCard;

    @Override
    public SysUserResp toResp() {
        return Beans.copyProperties(this, SysUserResp.class);
    }
}